package com.wwp.tbshop.util.utils;

/**
 * Author :leilei on 2016/11/11 2326.
 */
public class TimeTools {
    //毫秒换成00:00:00
    private static final String TAG = "TimeTools";
    public static String getCountTimeByLong(long finishTime) {
        int totalTime = (int) (finishTime / 1000);//秒
        int hour = 0, minute = 0, second = 0;

        if (3600 <= totalTime) {//如果时间超过一个小时
            hour = totalTime / 3600;//获取小时
            totalTime = totalTime - 3600 * hour;//获取出去小时后的时间
        }
        if (60 <= totalTime) {//如果小于60分钟,这不明摆着的么;
            minute = totalTime / 60;//获取分钟;
            totalTime = totalTime - 60 * minute;//剩下的是秒钟;
        }
        if (0 <= totalTime) {//如果秒钟大于0;即存在秒数;
            second = totalTime;
        }
        StringBuilder sb = new StringBuilder();

        if (hour < 10) {
            sb.append("0").append(hour).append(":");
        } else {
            sb.append(hour).append(":");
        }
        if (minute < 10) {
            sb.append("0").append(minute).append(":");
        } else {
            sb.append(hour).append(":");
        }
        if (second < 10) {
            sb.append("0").append(second);
        } else {
            sb.append(second);
        }
        return sb.toString();
    }
}
